﻿//IMessageFactoryWrapper.cs
//Copyright (c) 2013 StockSharp LLC, all rights reserved.
//This code module is part of StockSharp library.
//This code is licensed under the GNU GENERAL PUBLIC LICENSE Version 3.
//See the file License.txt for the license details.
//More info on: http://stocksharp.com

namespace StockSharp.Plaza.Wrappers
{
	/// <summary>
	/// Фабрика для создания сообщений.
	/// </summary>
	interface IMessageFactoryWrapper
	{
		/// <summary>
		/// Инициализация объекта.
		/// </summary>
		/// <param name="structFile">Файл, содержащий схему сообщений.</param>
		/// <param name="signFile">Не используется.</param>
		void Init(string structFile, string signFile);

		/// <summary>
		/// Создание сообщения по имени.
		/// </summary>
		/// <param name="msgName">Имя сообщения</param>
		/// <returns></returns>
		IMessageWrapper CreateMessageByName(string msgName);
	}

	class MessageFactoryWrapper32 : IMessageFactoryWrapper
	{
		private readonly P2ClientGateMTA32.CP2BLMessageFactory _factory;

		public MessageFactoryWrapper32()
		{
			_factory = new P2ClientGateMTA32.CP2BLMessageFactory();
		}

		void IMessageFactoryWrapper.Init(string structFile, string signFile)
		{
			_factory.Init(structFile, signFile);
		}

		IMessageWrapper IMessageFactoryWrapper.CreateMessageByName(string msgName)
		{
			return new MessageWrapper32(_factory.CreateMessageByName(msgName));
		}
	}

	class MessageFactoryWrapper64 : IMessageFactoryWrapper
	{
		private readonly P2ClientGateMTA64.CP2BLMessageFactory _factory;

		public MessageFactoryWrapper64()
		{
			_factory = new P2ClientGateMTA64.CP2BLMessageFactory();
		}

		void IMessageFactoryWrapper.Init(string structFile, string signFile)
		{
			_factory.Init(structFile, signFile);
		}

		IMessageWrapper IMessageFactoryWrapper.CreateMessageByName(string msgName)
		{
			return new MessageWrapper64(_factory.CreateMessageByName(msgName));
		}
	}
}